package com.cea.papyrustest.load;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Element;

import com.cea.papyrus.core.commands.AddUMLElementToDiagram;
import com.cea.papyrus.core.commands.UMLElementCreateCommand;
import com.cea.papyrus.core.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
import com.cea.papyrustest.uml.createcommand.PapyrusCommandTest;

/**
 * Test class for lots of {@link Class} creation command
 * @author Remi Schnekenburger
 */
public class ThousandClassesCommandTest extends PapyrusCommandTest{

	protected static int NUMBER = 150;
	protected static int STEP= 15;
	
	/**
	 * Default constructor
	 * @param name the name oif the test case
	 */
	public ThousandClassesCommandTest(String name) {
		super(name);	
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		papyrusCommand= new UMLElementCreateCommand(org.eclipse.uml2.uml.Class.class,model);
		
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrustest.PapyrusCommandTest#testExecute()
	 */
	@Override
	public void testExecute() {
		for(int i = 0; i < NUMBER ; i++) {
			stack.execute(papyrusCommand);
			Element elt=((UMLElementCreateCommand)papyrusCommand).getElement();
			AddUMLElementToDiagram addcommand=new AddUMLElementToDiagram(elt, ((AbstractGraphicalPageWithFlyoutPalette)papyrusEditor.getActiveEditor()).getDiagramModel(),new Point((i%STEP)*110,new Double(Math.floor(i/STEP)).intValue()*110),null);
			stack.execute(addcommand);
			System.err.print("\r"+i+"/"+NUMBER);
		}
	}
}
